// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=1001

//#define COMPILE
// 간단한 방정식 세우기
#ifdef COMPILE

#include <fstream>
using namespace std;
ifstream in("input.txt");
ofstream out("output.txt");

int main() {
	int x;
	int y;
	in >> x >> y;
	while ((x != 0) || (y != 0)) {
		if ((0 <= x) && (x <= 1000) && (0 <= y) && (y <= 4000)) {
			if ((y % 2 == 0) && ((y / 2 >= x)) && (2 * x >= y / 2)) {
				out << y / 2 - x << " " << 2 * x - y / 2 << endl;
			} else {
				out << 0 << endl;
			}
		} else {
			out << "INPUT ERROR!" << endl;
		}
		in >> x >> y;
	}

	out.close();
	in.close();

	return 0;
}
#endif
